package com.hzbank.generate.controller;

import com.hzbank.generate.ServiceoMain;
import com.hzbank.generate.ServiceoMain2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/do")
public class TestController {
    @Autowired
    private ServiceoMain serviceoMain;
    @Autowired
    private ServiceoMain2 serviceoMain2;


    @GetMapping("/long/{count}")
    public String doLong(@PathVariable("count") int count){
        log.info("共需："+ count);
        long start = System.currentTimeMillis();
        for (int i = 0; i < count; i++) {
            serviceoMain.generate("index = " + i);
        }
        long end = System.currentTimeMillis();
        long haomiao = end-start;
        long miao = haomiao/1000;
        double fen = (double) (miao/60);
        double shi = (double) (fen/60);
        log.info(count+"次共需"+haomiao+"毫秒");
        log.info(count+"次共需"+miao+"秒");
        log.info(count+"次共需"+fen+"分");
        log.info(count+"次共需"+shi+"小时");
        return "success";
    }
    @GetMapping("/long2/{count}")
    public String doLong2(@PathVariable("count") int count){
        log.info("共需："+ count);
        long start = System.currentTimeMillis();

        serviceoMain2.initAreaCode();

        for (int i = 0; i < count; i++) {
            serviceoMain2.generate("index = " + i);
        }
        long end = System.currentTimeMillis();
        long haomiao = end-start;
        long miao = haomiao/1000;
        double fen = (double) (miao/60);
        double shi = (double) (fen/60);
        log.info(count+"次共需"+haomiao+"毫秒");
        log.info(count+"次共需"+miao+"秒");
        log.info(count+"次共需"+fen+"分");
        log.info(count+"次共需"+shi+"小时");
        return "success";
    }

    @GetMapping("count")
    public Map count(){
        return serviceoMain.count();
    }




}


















